import request from '@/config/axios'
import type { Dayjs } from 'dayjs';

/** 用户阅读记录信息 */
export interface UserReadingHistory {
          id: number; // 记录唯一ID
          userId?: number; // 用户ID
          bookId?: number; // 书籍ID
          isCompleted?: number; // 是否已读完
          lastPage?: number; // 上次阅读页码
          totalTime?: number; // 总阅读时间（分钟）
          readCount?: number; // 阅读次数
          creator: string; // 创建者
          createTime: string | Dayjs; // 创建时间
          updater: string; // 更新者
          updateTime: string | Dayjs; // 更新时间
          deleted: boolean; // 是否删除
  }

// 用户阅读记录 API
export const UserReadingHistoryApi = {
  // 查询用户阅读记录分页
  getUserReadingHistoryPage: async (params: any) => {
    return await request.get({ url: `/pickbook/user-reading-history/page`, params })
  },

  // 查询用户阅读记录详情
  getUserReadingHistory: async (id: number) => {
    return await request.get({ url: `/pickbook/user-reading-history/get?id=` + id })
  },

  // 新增用户阅读记录
  createUserReadingHistory: async (data: UserReadingHistory) => {
    return await request.post({ url: `/pickbook/user-reading-history/create`, data })
  },

  // 修改用户阅读记录
  updateUserReadingHistory: async (data: UserReadingHistory) => {
    return await request.put({ url: `/pickbook/user-reading-history/update`, data })
  },

  // 删除用户阅读记录
  deleteUserReadingHistory: async (id: number) => {
    return await request.delete({ url: `/pickbook/user-reading-history/delete?id=` + id })
  },

  /** 批量删除用户阅读记录 */
  deleteUserReadingHistoryList: async (ids: number[]) => {
    return await request.delete({ url: `/pickbook/user-reading-history/delete-list?ids=${ids.join(',')}` })
  },

  // 导出用户阅读记录 Excel
  exportUserReadingHistory: async (params) => {
    return await request.download({ url: `/pickbook/user-reading-history/export-excel`, params })
  }
}